<template>
  <div class="product-section recommended-products">
    <h3>推荐商品</h3>
    <div class="product-grid">
      <div
          class="product-card"
          v-for="(product, index) in products"
          :key="index"
      >
        <img :src="product.image" :alt="product.name">
        <div class="product-card-content">
          <div class="product-card-title">{{ product.name }}</div>
          <div class="product-card-price">¥{{ product.price }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    products: {
      type: Array,
      required: true
    }
  }
}
</script>

<style scoped>
.product-section {
  margin-top: 30px;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.product-section h3 {
  font-size: 20px;
  margin-bottom: 15px;
  color: #212529;
  border-left: 4px solid #007BFF;
  padding-left: 10px;
}

.recommended-products {
  margin-top: 30px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.product-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: transform 0.3s ease;
}

.product-card:hover {
  transform: translateY(-5px);
}

.product-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.product-card-content {
  padding: 15px;
}

.product-card-title {
  font-size: 16px;
  margin-bottom: 10px;
  color: #212529;
  height: 40px;
  overflow: hidden;
}

.product-card-price {
  color: #e60012;
  font-weight: bold;
  font-size: 18px;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
</style>